"use strict";

const files = require.context('./module', false, /\.js$/);

class Ajax {
    static options;

    constructor(options, Store) {
        const that = this;
        const opts = {...Ajax.options, ...options};
        const $ajax = {}
        files.keys().forEach((key) => {
            if (!/.?\/?([a-zA-Z]+).js$/.test(key)) return;
            if (key === './index.js' || !files(key).default) return;
            const name = key.replace(/^.?\/?([a-zA-Z]+).js$/ig, "$1")
            if (!/^[a-z]+$/i.test(name)) return;
            const k = name.slice(0, 1).toUpperCase() + name.slice(1);
            that[k] = new (files(key).default)({...opts}, Store);
        });
    }
}

exports.Ajax = Ajax;


